package com.lb.statck.config;

import com.lb.statck.service.OrderService;
import com.wechat.pay.contrib.apache.httpclient.util.PemUtil;
import com.wechat.pay.java.core.Config;
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
import com.wechat.pay.java.core.RSAPublicKeyConfig;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.client.WebClient;

import java.io.InputStream;
import java.security.PrivateKey;
import java.util.Objects;

/**
 * @Description: 支付配置类
 * @Author: xiaoliu
 * @Date: 2025/6/13
 * @Version: V1.0
 * @JDK: JDK17
 */
@Configuration
@Data
public class WechatPayConfig {
    /**
     * 小程序公众号的appId
     */
    @Value("${wx.miniapp.apiV3Key}")
    private String appId;

    /**
     * 回调地址
     */
    @Value("${wx.miniapp.payNotifyUrl}")
    private String notifyUrl;

    /**
     * 商户号
     */
    @Value("${wx.miniapp.merchantId}")
    private String merchantId;

    /**
     * 商户API私钥路径
     */
    @Value("${wx.miniapp.privateKeyPath}")
    private String privateKey;

    /**
     * 商户证书序列号
     */
    @Value("${wx.miniapp.merchantSerialNumber}")
    private String merchantSerialNumber;

    /**
     * 商户APIV3密钥
     */
    @Value("${wx.miniapp.apiV3Key}")
    private String apiV3Key;

    @Value("${spring.weixin.mchId}")
    private String mchId;
    @Autowired
    private WebClient webClient;
    //@Autowired
    //private WxPayConfig wxPayConfig;

    @Value("${wx.miniapp.wechatPayCertificatePath}")
    private  String wechatPayCertificatePath;
    @Value("${spring.weixin.appid}")
    private String appID;
    @Value("${spring.weixin.appsecret}")
    private String appSecret;

    @Value("${wx.miniapp.privateKeyPath}")
    private String privateKeyPath;



    @Value("${wx.miniapp.payNotifyUrl}")
    private String payNotifyUrl;
    @Value("${wx.miniapp.refundNotifyUrl}")
    private String refundNotifyUrl;
    @Value("${wx.miniapp.publicKeyId}")
    private String publicKeyId;
    @Value("${wx.miniapp.publicKeyPath}")
    private String publicKeyPath;
    @Autowired
    private OrderService orderService;

}
